﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Markup;
using System.Reflection;

namespace exsportance.Silverlight.Common.Controls
{
    public partial class DebugWindow : UserControl
    {
        public DebugWindow()
        {
            InitializeComponent();
        }

        public void Write(string message)
        {
            setText(txtMessages.Text + message);
        }

        public void WriteLine(string message)
        {
            setText(txtMessages.Text + message + Environment.NewLine);
        }

        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            setText(string.Empty);
        }

        private void setText(string text)
        {
            txtMessages.Text = text;
            if (txtMessages.Text.Length > 0)
                txtMessages.SelectionStart = txtMessages.Text.Length - 1;
        }
    }
}
